import axios from 'axios'
import { PureComponent } from 'react';
import { connect } from 'react-redux';
import { ChangeBanneraction } from '../store/createActors';

class Category extends PureComponent
{
    componentDidMount()
    {
        //获取数据
        axios.get('http://123.207.32.32:8000/home/multidata').then(res => {
            console.log(res);
            //获取到数据后将数据放到store中
            console.log(res.data.data.banner.list);
            const banner = res.data.data.banner.list;
            this.props.changeBanners(banner);
        })
    }

    render()
    {
      return(
       <div>
       <h2>Category:</h2>    
       </div>
    )    
    }
}

const mapDispatchtoProps = (dispatch) => {
    return {
        changeBanners: (banners) => {
            dispatch(ChangeBanneraction(banners))
        }
    }
}

export default connect(null,mapDispatchtoProps)(Category);

